package com.ld.control.business.region.controller;

import com.ld.control.business.region.service.RegionService;
import com.ld.control.business.region.vo.RegionReqVo;
import com.ld.control.business.region.vo.RegionRespVo;
import com.ld.control.common.vo.GenerateListVo;
import com.ld.control.common.ResultResponse;
import com.ld.control.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Tag(name = "区域相关接口")
@RestController
public class RegionController {

    @Autowired
    private RegionService regionService;

    @GetMapping("/api/centralControl/region/getList")
    @Operation(summary = "区域列表", description = "区域列表")
    public ResultResponse<GenerateListVo<RegionRespVo>> getList(){
        List<RegionRespVo> reginList = regionService.getList();
        return ResultResponse.success(new GenerateListVo<>(reginList));
    }

    @PostMapping("/api/centralControl/region/add")
    @Operation(summary = "新增设备区域信息")
    public ResultResponse<ResultResponseEnum> add(@RequestBody RegionReqVo reqVo){
        regionService.add(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/centralControl/region/update")
    @Operation(summary = "修改设备区域信息")
    public ResultResponse<ResultResponseEnum> update(@RequestBody RegionReqVo reqVo){
        regionService.update(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/centralControl/region/delete")
    @Operation(summary = "删除设备区域信息")
    public ResultResponse<ResultResponseEnum> update(@RequestParam Long id){
        regionService.delete(id);
        return ResultResponse.success();
    }



}
